package me.ereach.streams;

import java.util.List;

public class Main06SlicingStream {
    public static void main(String[] args) {
        List<Movie> movies = List.of(
                new Movie("a", 10),
                new Movie("b", 15),
                new Movie("c", 20)
        );

        System.out.println("===limit");
        movies.stream()
                .limit(2)
                .forEach(m -> System.out.println(m.getTitle()));

        System.out.println("===skip");
        movies.stream()
                .skip(2)
                .forEach(m -> System.out.println(m.getTitle()));

        // for sorted stream,
        System.out.println("===takeWhile");
        movies.stream()
                .takeWhile(m -> m.getLikes() <= 15)
                .forEach(m -> System.out.println(m.getTitle()));

        System.out.println("===dropWhile");
        movies.stream()
                .dropWhile(m -> m.getLikes() <= 15)
                .forEach(m -> System.out.println(m.getTitle()));
    }
}
